import request from '@/utils/request';
import type { SkuResponseData, SkuInfoData } from './type';

enum API {
  //sku列表
  SKU_URL = '/admin/product/list/',
  //上架
  SALE_URL = '/admin/product/onSale/',
  //下架
  CANCELSALE_URL = '/admin/product/cancelSale/',
  //获取商品信息
  SKUINFO_URL = '/admin/product/getSkuInfo/',
  //删除商品
  DELETESKU_URL = '/admin/product/deleteSku/',
}

/**
 *
 *  sku列表
 * @param page 页数
 * @param limit 页面数据数量
 */
export const reqSkuList = (page: number, limit: number) => {
  return request<any, SkuResponseData>({
    url: API.SKU_URL + `${page}/${limit}`,
    method: 'get',
  });
};

/**
 *
 *  上架
 * @param skuId skuId
 */
export const reqSaleSku = (skuId: number) => {
  return request<any, any>({
    url: API.SALE_URL + skuId,
    method: 'get',
  });
};

/**
 *
 *  下架
 * @param skuId skuId
 */
export const reqCancelSaleSku = (skuId: number) => {
  return request<any, any>({
    url: API.CANCELSALE_URL + skuId,
    method: 'get',
  });
};

/**
 *
 *  获得sku信息
 * @param skuId skuId
 */
export const reqSkuInfo = (skuId: number) => {
  return request<any, SkuInfoData>({
    url: API.SKUINFO_URL + skuId,
    method: 'get',
  });
};

/**
 *
 *  删除sku
 * @param skuId skuId
 */
export const reqDeleteSku = (skuId: number) => {
  return request<any, any>({
    url: API.DELETESKU_URL + skuId,
    method: 'get',
  });
};
